//判断是否是开发者环境
const isDev = false;
//开发环境不校验域名以及TLS版本
const devHost = 'http://192.168.0.152:8537';
// const devHost = 'https://daitougou.com/dtg';
// const devHost = 'http://192.168.0.131:8537';
// const devHost = 'http://47.108.54.171:8600/dtg';
const prodHost = 'https://daitougou.com/dtg';
// const prodHost = 'https://app.daitougou.com/app';
const SUCCESS = 8200;
// 文件路径分隔符：/
const SEPARATOR_PATH = '/';
/**
 * 
 * 获取服务端主机地址
 */
const getHost = function () {
  return isDev ? devHost : prodHost;
}
/**
 * 判断服务端响应码是否成功？
 * 
 * @param resultCode 服务端响应码
 * 
 */
const isSuccess = function (resultCode) {
  return resultCode == SUCCESS;
}

function isPositiveFloat(s) {
  var re = /^\d+\.*\d*$/;
  return re.test(s);
}

function isInteger(s) {
  var re = /^-{0,1}\d+$/;
  return re.test(s);
}

function isPositiveInteger(s) {
  var re = /^\d+$/;
  return re.test(s);
}

function isDate(s) {
  var re = /^\d{4}-\d{1,2}-\d{1,2}( \d{1,2}:\d{1,2}:\d{1,2}){0,1}$/;
  return re.test(s)
}

function isEmpty(s) {
  if (s == null) {
    return true;
  }
  var re = /^\s*$/;
  return re.test(s)
}

function isNotEmpty(s) {
  return !isEmpty(s);
}

function isEMail(s) {
  var re = /^([a-zA-Z0-9_\.\-]+?)@([a-zA-Z0-9\.\-]+?)\.([a-zA-Z]{2,3})$/;
  return re.test(s)
}

function isURL(s) {
  var re = /^http[s]?:\/\//;
  return re.test(s)
}

function isMobile(s) {
  var re = /^([1-9]\d{10}|[1-9]\d{12})$/;
  return re.test(s)
}

function isUserName(s) {
  var re = /^([a-zA-Z0-9]+)$/;
  return re.test(s)
}
module.exports = {
  getHost: getHost,
  isSuccess: isSuccess,
  isPositiveFloat: isPositiveFloat,
  isInteger: isInteger,
  isPositiveInteger: isPositiveInteger,
  isDate: isDate,
  isEmpty: isEmpty,
  isNotEmpty: isNotEmpty,
  isEMail: isEMail,
  isURL: isURL,
  isMobile: isMobile,
  isUserName: isUserName
}